// 引入路由对象
import router from './router';
// 引入vuex
import store from './store';

router.beforeEach((to, from, next) => {
  // 获取token
  const { token } = store.getters.getUserInfo;
  if (token) {
    if (to.path == '/login') {
      next(from.path);
    } else {
      next();
    }
  } else if (to.path == '/login') {
    next();
  } else {
    next('/login');
  }
  document.title = to.meta.title || '火星后台管理系统';
});
